// MethodThread.cpp: implementation of the MethodThread class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "kwclientcore.h"
#include "MethodThread.h"
#include "BaseMethodPerformer.h"
#include "BaseMethodCallback.h"
#include "MethodThreadPool.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

MethodThread::MethodThread(BaseMethodPerformer * pPerformer):
m_pPerformer(pPerformer)
{
  ASSERT(m_pPerformer);
}

MethodThread::~MethodThread()
{
}

bool MethodThread::ExitInstance()
{
  m_pPerformer->GetpCallback()->Callback(m_pPerformer);

  return CMethodThreadPool::Instance()->PostThreadMessage(WM_APP_METHODTHREADEXITED, (WPARAM)this, 0);
}

int MethodThread::Run()
{
  return m_pPerformer->Performing();
}
